/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controllers;

import db.StorageDb;
import db.StorageInterface;
import db.StorageItemDb;
import java.util.ArrayList;
import models.Storage;


/**
 *
 * @author Dan
 */
public class StorageController {

    private StorageInterface stoDb = new StorageDb();
    private Storage stoObj = null;
   
    public int addStorage(String name, String description, int amount) {
        Storage sto = new Storage(name, description, amount);
        return stoDb.addItem(sto);
    }
    public boolean updateStorage(Storage s){
        return stoDb.editItem(s);
    }

    public ArrayList<Storage> getAllStorage() {
        ArrayList<Storage> storageList = new ArrayList<Storage>();
        storageList = stoDb.getAllItems();
        return storageList;
    }
       public Storage getStorageById(int storageId) {
       stoObj =  stoDb.getStorage(storageId);
       return stoObj;
    }

    public void saveStorage(Storage stoObj)
    {
        this.stoObj  = stoObj;
    }
    public Storage getStorageObj()
    {
        return this.stoObj;
    }
    public int getStorageId()
    {
        return stoObj.getId();
    }
    public boolean deleteStorage(Storage id)
    {
        int stoId = id.getId();
        return stoDb.deleteItem(stoId);
    }
    
    
     
}
